## function to format LaTeX output
hl <- function(dat, digits = 3)	{

	if(is.matrix(dat) != TRUE)	{ cat("matrix input needed!","\n","\n"); return(invisible()) }
	if(ncol(dat) != 2)	{ cat("Incorrect number of columns !","\n","\n"); return(invisible()) }

	if(all(is.na(dat))) { return(dat) }

	dat.new <- matrix(NA,nrow(dat), 2)

	for(m in 1:nrow(dat))	{

		sym <- ""
		tvalue <- abs(as.numeric(dat[m,1]) / as.numeric(dat[m,2]))

		if(tvalue >= qnorm(.95))  sym <- "^{*}"
		if(tvalue >= qnorm(.975)) sym <- "^{**}"
		if(tvalue >= qnorm(.995)) sym <- "^{***}"

     	dat.new[m,1] <- 
     	paste("$", format(round(as.numeric(dat[m,1]), digits = digits),
     	scientific = FALSE, nsmall = digits), sym[], "$", sep = "")

     	dat.new[m,2] <- 
     	paste("$(", format(round(as.numeric(dat[m,2]), digits = digits),
     	scientific = FALSE, nsmall = digits),")$", sep = "")

							}

     	return(dat.new)
     }
